home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 476-500 / disk_500 / signal / signal.doc < prev    next >
Text File  |  1992-05-06  |  3KB  |  75 lines

  1. OVERVIEW:
  2.  
  3. SIGNAL and WAITFOR are companion programs designed to make it easy to write
  4. script files that use RUN EXECUTE to start other script files.  Often one
  5. EXECUTE script must be synchronised with the operation of another (in order to
  6. avaid disk thrashing, for instance).  AmigaDOS does not provide a convenient
  7. mechanism for accomplishing this (one must use FAILAT and WAIT in one process
  8. and BREAK in the other; this requires that one process know the task number of
  9. the parent, and there is no easy way to do this).  SIGNAL and WAITFOR provide 
  10. such a synchronization mechanism.
  11.  
  12.  
  13. HOW TO USE SIGNAL AND WAITFOR:
  14.  
  15. In order to avoid the problem of one task having to know the task number of
  16. the other, WAITFOR and SIGNAL provide "named" signals; that is, the two
  17. processes communicate by using agreed-upon names.  For example, if the
  18. main process included the commands:
  19.  
  20.     RUN EXECUTE SubProcess.COM
  21.     WAITFOR OK-Signal
  22.     ECHO "Sub-Process Complete."
  23.  
  24. and SubProcess.COM contained:
  25.  
  26.     ECHO "Sub-Process Doing its Work."
  27.     SIGNAL OK-Signal
  28.  
  29. then the RUN command would start the second process running, and the WAITFOR
  30. would block until the second process performed the SIGNAL command.  Thus the
  31. output would be:
  32.  
  33.     Sub-Process Doing its Work.
  34.     Sub-Process Complete.
  35.  
  36.  
  37. The genereal form of the commands are:
  38.  
  39.     WAITFOR <name>
  40.     SIGNAL <name>
  41.  
  42. where <name> is any string of characters.  WAITFOR <name> will only complete
  43. when a corresponding SIGNAL <name> is executed.  Note that capitalization and
  44. spacing (except for leading spaces) are not ignored.  The same name can not be
  45. used by more than two processes at once (one SIGNAL and WAITFOR pair), but by
  46. using different names, many processes can be linked together at one time.
  47.  
  48. There is no mechanism currently in WAITFOR to allow a process to wait for 
  49. more than one signal at once.
  50.  
  51. Both WAITFOR and SIGNAL can be cancelled by the user pressing CTRL-C (or using
  52. the BREAK command from DOS).
  53.  
  54. If the SIGNAL command happens to be executed BEFORE the WAITFOR command,
  55. SIGNAL will attempt to signal again every 2 seconds for 20 seconds.  If no
  56. WAITFOR command has been performed within that time, SIGNAL will exit with an
  57. error status.
  58.  
  59. The files MainProcess.COM and SubProcess.COM included in the distribution
  60. show a complete example of how to use SIGNAL and WAITFOR to synchronize
  61. process activity.  To see them in action, issue the command:
  62.  
  63.     1> EXECUTE MAINPROCESS.COM
  64.  
  65.  
  66. AUTHOR:
  67.  
  68. Signal and WaitFor
  69. Copyright (c) 1989 by Davide P. Cervone, all rights reserved.
  70.  
  71. Davide P. Cervone
  72. Department of Mathematics, Box 1917                 ST402523@BROWNVM.BITNET
  73. Brown University                                    st402523@brownvm.brown.edu
  74. Providence, Rhode Island  02912                     dpvc@fermat.math.brown.edu
  75.